#!/bin/awk -f
## Synopsis : extract_copaout N
FNR==1{
  tn=$1;mu=$2;ns=$3;
  if(!n)n=$3; # by default, take the last copas.out
}
FNR==2{
  ba[1]=$0;
  getline;
  ba[2]=$0;
  print ba[1];
  print ba[2];
  print tn,mu," decoration.inp";
  for(i=1;i<=n-1;i++){
    getline; beta[i]=$1; ene[i]=$2;
    for(j=1;j<=tn;j++){
      getline;
    }
    getline; np=$1; # parameters
    for(j=1;j<=np;j++){
      getline;
    }
    getline; nts=$1; # object-center shifts
    for(j=1;j<=nts;j++){
      getline;
    }
    for(j=1;j<=tn;j++){
      getline; na=$1;
      for(k=1;k<=na;k++){
	getline;
      }
    }
  }
  getline; beta[n]=$1; ene[n]=$2;
  for(j=1;j<=tn;j++){
    getline; print $0;
  }
  getline; np=$1; print $0; # parameters
  for(j=1;j<=np;j++){
    getline; print $0;
  }
  getline; nts=$1; print $0; # object-center shifts
  for(j=1;j<=nts;j++){
    getline; print $0; 
  }
  for(j=1;j<=tn;j++){
    getline; na=$1; print $0;
    for(k=1;k<=na;k++){
      getline; print $0;
    }
  }  
  exit
}
END{}
